/*
 * fixedtree.h
 *
 *  Created on: Mar 29, 2011
 *      Author: Mo
 */
#pragma once
#include "fixedtreenode.h"

/**
 * This class implements an ID3 decision tree in a fixed data structure.
 * No matter what the final structure of the tree is, this class creates nodes for
 * a full tree. if a node is not used, it's "decision" label will be blank.
 * Each node has a fixed number of children (equal to CELLSTATES).
 */
class FixedTree
{
private:
	int nodeNum;			//!< The total number of nodes in the tree.

	/**
	 * A pointer to the 2D array of nodes. This tree has a fixed structure, and does not need any 
	 * link between the parent and the child. Each node has specifically 'CELLSTATES' children. There are
	 * 'rule size + 1' levels in the tree. The children of node(i,j) are the nodes (i+1,(j-1)*CELLSTATES), 
	 * (i+1,(j-1)*CELLSTATES+1), ... (i+1, [(j-1)*CELLSTATES]+CELLSTATES-1).
	 * The parent of the node (i,j) is node (i-1, j/CELLSTATES)
	 */
	FixedTreeNode** node;

	/** The rule base for which we are creating the tree. */
	RuleBase rootRB;

	/** Not used for now. Can be used as another separability measure of the RB later.*/
	double averageDepth;

	int emptyNodeNum;
	int nonEmptyNodeNum;

public:
	int getnonEmptyNodeNum();
	int getEmptyNodeNum();
	int getNodeNum();
	void print(void);
	FixedTree();
	FixedTree (FixedTree& other);
	/**
	 * Constructor and the main function. Creates an ID3 tree for a rule base.
	 * It also updates the nodeNum, emptyNodeNum and nonEmptyNodeNum members.
	 * \param rb the rule base for which the ID3 it being generated.
	 */
	FixedTree (RuleBase& rb);
	~FixedTree();
};

